<?php 
include('header.php');
include('menu.php');
error_reporting(E_ALL || E_STRICT);
include("connection/connection.php");
$district1=$_REQUEST['district1'];
$id=$_GET['id'];
$qry1="select population_factor,district_name from tbl_lookup_pop_factor where district_id=$id";
$result1=mysql_query($qry1);
$x=mysql_fetch_row($result1);
if(isset($_REQUEST['add']))
{
$newvalue=$_REQUEST['newpop'];
$district1=$_POST['district1'];
$qry2="UPDATE tbl_lookup_pop_factor SET population_factor=$newvalue  WHERE district_id='$district1'";
$result2=mysql_query($qry2);
if($result2)
{
$msg1="Population Factor has been successfully updated";
}
}

?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Create User</title>
<script language="javascript" type="text/javascript" src="js/validate.js"></script>
</head>
<body>
	<!--<table>
			<tr>
				<td><?php //include('header.php');?></td>
			</tr>
	</table>-->	
	<table width="443">
			<tr>
				<!--<td align="left" width="300"><?php //include('menu.php');?></td>-->
				<td valign="top">
<table border="0" width="300px" id="table21" height="60%" cellspacing="1" style=" padding-top:0px" >
<tr bgcolor="FF9966">
	<td height="29" align="left" valign="top" bgcolor="#FF9966">&nbsp;</td>
	<td bgcolor="#FF9966" align="left" valign="top">&nbsp;</td>
	<td bgcolor="#FF9966" align="left" valign="top" colspan="5">&nbsp;</td>
	<td height="29" align="left" valign="top" bgcolor="#FF9966">&nbsp;</td>
	<td bgcolor="#FF9966" align="left" valign="top">&nbsp;</td>
</tr>
<tr>
	<td bgcolor="#E5E5E5" align="left" valign="top" width="1%">&nbsp;</td>
	<td bgcolor="#E5E5E5" align="left" valign="top" width="5%">
	<!--<img border="0" src="images/my_pag2.jpg">--></td>
	<td bgcolor="#E5E5E5" align="left" width="91%" colspan="5">
	<span lang="en-us">&nbsp;</span><span lang="en-us" style="font-size: 8.5pt"><font face="Verdana" color="#006699"><b>POPULATION FACTOR</b></font></span></td>
	<td bgcolor="#E5E5E5" align="left" valign="top" width="1%">&nbsp;</td>
	<td bgcolor="#E5E5E5" align="left" valign="top" width="5%">
</tr>

<tr>
	<td bgcolor="#E5E5E5" align="left" valign="top" colspan="7">
	<span style="font-size: 3pt" lang="en-us">&nbsp;</span></td>
	<td bgcolor="#E5E5E5" align="left" valign="top" colspan="7"></td>
</tr>
<tr>
	<td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
	<td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
	<td bgcolor="#E5E5E5" align="left" valign="top" colspan="5" bordercolor="#F2F2F2"></td>
	<td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
	<td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
</tr>
<tr>
	<td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
	<td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
	<td align="left" valign="top" colspan="5">
	<table border="0" width="750" id="table22" cellspacing="0" cellpadding="0">
								<!--<tr>
									<td bgcolor="#050505" height="1"></td>
								</tr>!-->
								<tr>
									<td>
										<table border="0" width="100%" id="table23" cellspacing="0" cellpadding="0">
											<tr>
												<td>&nbsp;</td>
											</tr>
											<tr>
												<td align="center">
													<b><a href="addfact.php" style="text-decoration:none; color:#006699">Add Factor</a>&nbsp;|&nbsp;<a href="editfact.php" style="text-decoration:none; color:#006699">Edit Factor</a>&nbsp;|&nbsp;<a href="listfact.php" style="text-decoration:none; color:#006699">List All factor</a></b><br/><h5>Edit Factor</h5>
													
													<form action="" method="post" name="pop" id="pop" onSubmit="return fld_pop()">
													<div style="background-color:#FFFFCC; width:330px; height:25px"><h5 style="padding-top:5px"><font color="#000000"><?php echo $msg1; ?></font></h5></div>
													<table style="padding-top:15px">
													<tr><td><font face="Verdana" style="font-size: 8.5pt" color="#000000">Select District</font></td><td>
<select size="1" name="district1"  style="font-size: 8pt; font-family: Verdana; border:1px solid black;  border-width: 1px" onChange="getid()" id="district1">
		<option value="0">Select District</option>
		<?php
		$qry="select DISTINCT district_id, district_name from tbl_lookup_location order by district_name";
		echo $qry;
		$result=mysql_query($qry);
          while($y=mysql_fetch_array($result))
		   {
		 	if($x[1]==$y['district_name'])
	  	      {
			  ?>
		  <option  value="<?php echo $y['district_id'];?>" selected><?php echo $y['district_name'];?></option>
		  <?php
	  	     }else
			   {
			   ?>
		     <option  value="<?php echo $y['district_id'];?>"><?php echo $y['district_name'];?></option>
			 <?php
	           }
	 
		  ?>
         
		  <?php
		  } 
		  ?>
</select>&nbsp;&nbsp;&nbsp;&nbsp;<b><?php echo $msg;?></b></td></tr>

				<tr><td><font face="Verdana" style="font-size: 8.5pt" color="#000000">Existing Population Factor:</font>
		   		</td><td><input type="text" name="pop" value="<?php echo $x[0];?>" style="font-size: 8pt; font-family: Verdana; border:1px solid black;  border-width: 1px" />
				</td></tr>
				<tr><td><font face="Verdana" style="font-size: 8.5pt" color="#000000">Enter New Population Factor:</font>
		   		</td><td><input type="text" id="newpop" name="newpop" value="" style="font-size: 8pt; font-family: Verdana; border:1px solid black;  border-width: 1px" />
				</td></tr>
				<tr><td colspan="2"><input type="submit" value="Update" name="add" style="border:1px solid #000000; font-size: 8pt; font-family: Verdana; "></td></tr>
													</table>
													 
													</form>
												
											</td>
											
										</tr>
									</table>
								
					</form>
					</td>
										
				</tr>
				
				
				<tr>
					<td><p align="center"></td>
				</tr>
				<tr>
					<td>&nbsp;</td>
				</tr>
</table>					
</td>
<td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
	<td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
 </tr>

         <tr>
            <td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
								  <td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
								  <td bgcolor="#E5E5E5" align="left" valign="top" colspan="5">
								    <font color="#000000" face="Verdana">
							        <span style="font-size: 8.5pt">
							         
						            </span></font></td>
									 <td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
								  <td bgcolor="#E5E5E5" align="left" valign="top">&nbsp;</td>
									
 </tr>
</table>


</body>
</html>
<script language='javascript'>
function fld_pop()
{
if(document.getElementById('district1').value==0)
{
alert("Please choose district name");
document.getElementById('district1').focus();
return false;
}
if(document.getElementById('newpop').value==0)
{
alert("Please Enter Population Factor");
document.getElementById('newpop').focus();
return false;
}
if(isNaN(document.getElementById('newpop').value))
{
alert("Please Enter Numeric Value");
document.getElementById('newpop').focus();
return false;
}
}

function getid(id)
{	
	 
	 var popvalue=document.getElementById('district1').value;
	       		  document.location='editfact.php?id='+popvalue;
		
}
</script>


